package com.marst.first.controller;

import com.marst.first.bean.Role;
import com.marst.first.bean.VO.Result;
import com.marst.first.service.RoleService;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("role")
public class RoleController {

    @Autowired
    private RoleService roleService;



    @RequestMapping(method = RequestMethod.POST,value = "addRole")
    public Result addRole(@RequestBody Role role) {

        return roleService.addRole(role);
    }


    /** 
    * @Description: 获取所有角色信息
    * @Param: []
    * @return: com.marst.first.bean.VO.Result
    * @Author: ZhaoYang
    * @Date: 2024/10/23
    */
    
    @RequestMapping(method = RequestMethod.GET,value = "getAllRole")
    public  Result getAllRole(int pageSize, int pageNum, String name) {
        return roleService.getAllRole(pageSize, pageNum, name);
    }


    @RequestMapping(method = RequestMethod.GET,value = "getRoleById")
    public Result getRoleById(int id) {
        return roleService.getRoleById(id);
    }



    @RequestMapping(method = RequestMethod.GET,value = "deleteRoleById")
    public Result deleteRoleById(int id) {
        return roleService.deleteRoleById(id);
    }


    @RequestMapping(method = RequestMethod.GET,value = "deleteUserOnLogic")
    public Result deleteUserOnLogic(int id) {
        return roleService.deleteUserOnLogic(id);
    }

    @RequestMapping(method = RequestMethod.POST,value = "updateRoleById")
    public Result updateRoleById(@RequestBody Role role) {
        return roleService.updateRoleById(role);
    }

}
